﻿<%
Class sangong_class
    Public Function online()
        dim rs,sql,str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select count(*) as nid FROM qingtian_reton where DATEDIFF('h', [time], now()) < 1"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
		str=rs("nid")
	else
		str=0
	end if
	Rs.close
	set rs=nothing
	online=str
     End Function
    Public Function tj()
        dim rs,sql,i
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where nid="&qingtian.nid
	Rs.Open Sql,cn,1,3
	if not (rs.bof and rs.eof) then
        rs("time")=now
	else
	rs.addnew
        rs("time")=now
	rs("nid")=qingtian.nid
	end if
	rs.update
	Rs.close
	set rs=nothing
     End Function
    Public Function pd(str)
        dim rs,sql,strr
        strr=str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select money FROM qingtian_fangjian where id="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
           if conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")<rs("money") then
           qingtian.err("你的"&qingtian.bi&"不足,进入该房间最小需要"&rs("money")&""&qingtian.bi&".<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
           end if
        else
           qingtian.err("没有该房间,<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function moname(str)
        dim rs,sql,i,strr,moname1
        strr=str
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
	For i=1 to rs.RecordCount
        if i=1 then
        moname1="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>"
        else
        moname1="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>" & "," & moname1
        end if
	Rs.MoveNext
	next
        else
        moname1="暂无玩家"        
	end if
	Rs.close
	set rs=nothing
        moname=moname1
     End Function
    Public Function moname3(str,str2)
        dim rs,sql,i,strr,strr2
        strr=str
        strr2=str2
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 nid FROM qingtian_reton where aid="&strr&" and ton=2"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname3="(<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>)"
        else
        moname3="(空)[<a href='gamed.asp?act=1&amp;pid="&strr2&"&amp;id="&strr&"&amp;sid="&sidd&"'>坐庄</a>]"     
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function moname2(str,str2)
        dim rs,sql,i,strr,strr2
        strr=str
        strr2=str2
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr&" and ton<>2"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
	For i=1 to rs.RecordCount
        if i=1 then
        moname2="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>"
        else
        moname2="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>" & "," & moname1
        end if
	Rs.MoveNext
	next
        else
        moname2="空"     
	end if
	Rs.close
	set rs=nothing
        moname2="("&moname2&")[<a href='gamed.asp?act=2&amp;pid="&strr2&"&amp;id="&strr&"&amp;sid="&sidd&"'>坐闲</a>]"
     End Function
    Public Function tonn()
        dim rs,sql
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select ton,aid,bid FROM qingtian_reton where nid="&qingtian.nid
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        if rs("ton")<>0 then
        if rs("aid")=100000 then
        tonn="状态:游戏中<a href='gamedd.asp?action=login&amp;pid="&rs("bid")&"&amp;id="&rs("aid")&"&amp;sid=" & sidd & "'>返回</a>"
        else        
        tonn="状态:游戏中<a href='gamed.asp?action=login&amp;pid="&rs("bid")&"&amp;id="&rs("aid")&"&amp;sid=" & sidd & "'>返回</a>"
        end if
        else
        tonn="状态:等待游戏"
	end if
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function mobe(str)
        dim rs,sql,i,strr,moname1
        strr=str
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs.RecordCount
        else
        moname1=0
	end if
	Rs.close
	set rs=nothing
        mobe=moname1
     End Function
    Public Function moton(str,str1,str2)
        dim rs,sql,i,strr,strr1,strr2
        strr=str
        strr1=str1
        strr2=str2
        select case strr
        case "0"
        moton="等待玩家<a href='gamed.asp?pid="&strr2&"&amp;id="&strr1&"&amp;sid=" & sidd & "'>加入</a>"
        case "1"
        moton="游戏正在进行中"
        End Select
        if mobe(strr1)=4 then moton="游戏正在进行中"
     End Function
    Public Function suiji(str)
        dim monber,j,i,strr,temp,a1,a2,t,a
        strr=str
        monber="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52"
        monber=split(monber,",")
        Randomize()
        a=int(rnd*12+1)
        for i=1 to 100
            a1=int(rnd*51+1)
            a2=int(rnd*51+1)
        temp=monber(a1)
        monber(a1)=monber(a2)
        monber(a2)=temp
        next
        for j=a to strr
        if j=a then
        suiji=monber(a)
        else
        suiji=suiji&","&monber(j)
        end if
        next
        for t=0 to a-1
        suiji=suiji&","&monber(t)
        next       
     End Function
    Public Function namefa(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_fangd where id="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
        else
        qingtian.err("没有该房间,<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
	end if
	Rs.close
	set rs=nothing
        namefa=moname1
     End Function
    Public Function namere(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_reton where nid="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
	end if
	Rs.close
	set rs=nothing
        namere=moname1
     End Function
    Public Function namejian(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_fangjian where id="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
	end if
	Rs.close
	set rs=nothing
        namejian=moname1
     End Function
    Public Function yaopai1(str)
        dim strr,rs,sql,a1,a2,c,a,i,h,f,strr1,n
        strr=100000
        strr1=qingtian.nid        
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&strr&" and nid="&strr1&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                h=rs("h")
                c=split(h,",")
                if str=1 then
                ct=rs("c1")&","&c(0)
                else
                ct=rs("c")&","&c(0)
                end if
                ct=split(ct,",")
                n=0
                a=0
                for i=0 to Ubound(ct)
                if ct(i)<5 then
                n=n+1
                else
                if ct(i)>36 then 
                a=a+10
                else
                a1=ct(i) mod 4
                if a1<>0 then
                a1=int(ct(i)/4)+1
                else 
                a1=int(ct(i)/4)  
                end if
                a=a+a1
                end if
                end if
                next
                if n>0 then
                if a+n>11 then
                a=a+n
                else
                a=a+11+n-1
                end if
                end if
                if a>20 then 
                rs("ku")=1
                end if
                if str=1 and a>16 then rs("ku")=1                                   
                f=c(0)&","
                if str=1 then
                rs("a1")=a
                rs("c1")=rs("c1")&","&c(0) 
                else                
                rs("a")=a
                rs("c")=rs("c")&","&c(0)
                end if
                rs("h")=Replace(h, f, "")
	        rs.update                         
		end if
		Rs.close
	set rs=nothing
     yaopai1=true
     End Function
    Public Function yaopai(str1)
        dim strr,rs,sql,a1,a2,c,a,i,h,f,strr1,id,n
	id=Request.QueryString("id")
	if id="" then id=1
	if not isnumeric(id) then id=1
	id=clng(id)
        strr=id
        strr1=str1        
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&strr&" and nid="&strr1&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                h=cn.Execute("select h FROM qingtian_fangd where id="&strr)("h")
                c=split(h,",")
                ct=rs("c")&","&c(0)
                ct=split(ct,",")
                n=0
                a=0
                for i=0 to Ubound(ct)
                if ct(i)<5 then
                n=n+1
                else
                if ct(i)>36 then 
                a=a+10
                else
                a1=ct(i) mod 4
                if a1<>0 then
                a1=int(ct(i)/4)+1
                else 
                a1=int(ct(i)/4)  
                end if
                a=a+a1
                end if
                end if
                next
                if n>0 then
                if a+n>11 then
                a=a+n
                else
                a=a+11+n-1
                end if
                end if
                if a>20 then 
                rs("ku")=1
                end if
                if rs("ton")=2 and a>16 then rs("ku")=1                                   
                f=c(0)&","
                rs("a")=a
                rs("c")=rs("c")&","&c(0)
                h=Replace(h, f, "")
	        rs.update                         
		end if
		Rs.close
	set rs=nothing
                cn.Execute("update qingtian_fangd set h='"&h&"' where id="&strr)
     yaopai=true
     End Function
    Public Function game2()
        dim rs,sql,a1,a2,c,a,i,h,f
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid=100000 order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                h=suiji("51")
                c=split(h,",")
                if c(0)>36 then a1=10
                if c(0)<5 then a1=11
                if c(1)>36 then a2=10
                if c(1)<5 then a2=11
                if c(1)<5 and c(0)<5 then
                a1=1
                a2=1
                end if
                if a1<>10 and a1<>11 and a1<>1 then
                a1=c(0) mod 4
                if a1<>0 then
                a1=int(c(0)/4)+1
                else 
                a1=int(c(0)/4)  
                end if
                end if
                if a2<>10 and a2<>11 and a2<>1 then 
                a2=c(1) mod 4
                if a2<>0 then
                a2=int(c(1)/4)+1
                else 
                a2=int(c(1)/4)  
                end if
                end if
                a=a1+a2
                if a=21 then 
                rs("ku")=1
                a=1000
                end if
                rs("a")=a
                a=0 
                a1=0
                a2=0
                if c(2)>36 then a1=10
                if c(2)<5 then a1=11
                if c(3)>36 then a2=10
                if c(3)<5 then a2=11
                if c(3)<5 and c(2)<5 then
                a1=1
                a2=1
                end if
                if a1<>10 and a1<>11 and a1<>1 then
                a1=c(2) mod 4
                if a1<>0 then
                a1=int(c(2)/4)+1
                else 
                a1=int(c(2)/4)  
                end if
                end if
                if a2<>10 and a2<>11 and a2<>1 then 
                a2=c(3) mod 4
                if a2<>0 then
                a2=int(c(3)/4)+1
                else 
                a2=int(c(3)/4)  
                end if
                end if
                a=a1+a2
                if a=21 then 
                rs("ku")=1
                a=1000
                end if
                rs("a1")=a
                f=c(0)&","&c(1)&","&c(2)&","&c(3)&","
                rs("c")=c(0)&","&c(1)               
                rs("c1")=c(2)&","&c(3) 
                rs("h")=Replace(h, f, "")
	        rs.update                         
		end if
		Rs.close
	set rs=nothing
     End Function
    Public Function game1(str)
        dim strr,rs,sql,a1,a2,c,a,i,h,f
        strr=str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&strr&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                h=suiji("51")
                c=split(h,",")
		For i=1 to rs.RecordCount
                a1=0
                a2=0
                if c((i-1)*2)>36 then a1=10
                if c((i-1)*2)<5 then a1=11
                if c((i-1)*2+1)>36 then a2=10
                if c((i-1)*2+1)<5 then a2=11
                if c((i-1)*2+1)<5 and c((i-1)*2)<5 then
                a1=1
                a2=1
                end if
                if a1<>10 and a1<>11 and a1<>1 then
                a1=c((i-1)*2) mod 4
                if a1<>0 then
                a1=int(c((i-1)*2)/4)+1
                else 
                a1=int(c((i-1)*2)/4)  
                end if
                end if
                if a2<>10 and a2<>11 and a2<>1 then 
                a2=c((i-1)*2+1) mod 4
                if a2<>0 then
                a2=int(c((i-1)*2+1)/4)+1
                else 
                a2=int(c((i-1)*2+1)/4)  
                end if
                end if
                a=a1+a2
                if a=21 then 
                rs("ku")=1
                a=1000
                end if
                if rs("ton")=2 and a>17 then rs("ku")=1                
                f=c((i-1)*2)&","&c((i-1)*2+1)&","
                rs("a")=a
                rs("c")=c((i-1)*2)&","&c((i-1)*2+1)
                h=Replace(h, f, "")
	        rs.update                
		Rs.MoveNext
		next           
		end if
		Rs.close
	set rs=nothing
                cn.Execute("update qingtian_fangd set h='"&h&"' where id="&strr)
     End Function

    Public Function pai(str)
        dim strr,i,paii,a1
        strr=str
        strr=split(strr,",")
        for i=0 to Ubound(strr)
        a1=paizi(strr(i))
        if tu="&amp;aitd=1'>图片显示</a>" then
        paii=paii&"."&a1
        else
        paii="<img src='/game/sangon/img/"&strr(i)&".png' alt='"&a1&"' noselect = 'true' />" & paii
        end if
        next
        pai=paii
     End Function
    Public Function aapai(str)
        dim strr,i,paii,a1
        strr=str
        strr=split(strr,",")
        for i=0 to Ubound(strr)
        a1=paizi(strr(i))
        if tu="&amp;aitd=1'>图片显示</a>" then
        if i=0 then
        paii="空"
        else
        paii=paii&"."&a1
        end if
        else
        if i=0 then
        paii="<img src='/game/sangon/img/0.png' alt='空' noselect = 'true' />"
        else
        paii="<img src='/game/sangon/img/"&strr(i)&".png' alt='"&a1&"' noselect = 'true' />" & paii
        end if
        end if
        next
        aapai=paii
     End Function
    Public Function paizi(str)
        dim strr,a1,a2,paizi1
        strr=str
                a2=strr mod 4
                if a2<>0 then
                a1=int(strr/4)+1
                else 
                a1=int(strr/4)  
                end if
                select case a2
                case "0"
                paizi1="黑桃"
                case "1"
                paizi1="方块"
                case "2"
                paizi1="梅花"
                case "3"
                paizi1="红桃"
                End Select
                select case a1
                case "1"
                a1="A"
                case "11"
                a1="J"
                case "12"
                a1="Q"
                case "13"
                a1="K"
                End Select
                paizi=paizi1&a1
     End Function
    Public Function tu()
        dim rs,sql,str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 tu FROM qingtian_reton where nid="&qingtian.nid&""
	Rs.Open Sql,cn,1,3
        if Request.QueryString("aitd")="1" then rs("tu")=0
        if Request.QueryString("aitd")="0" then rs("tu")=1
	rs.update
        if rs("tu") then
        str="&amp;aitd=1'>图片显示</a>"
        else 
        str="&amp;aitd=0'>文字显示</a>"
        end if
	Rs.close
	set rs=nothing
	tu=str
     End Function
    Public Function gamejie2(str2)
        dim rs,sql,strs,i,pp,tt,aa,a,nid,d,pid,bodyy,aa1,mynid,toname
        mynid=qingtian.nid
        pid=str2
        toname=cn.execute("select toname from [qingtian_fangjian] where id="&pid&"")("toname")
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then  
                a=rs("a1")
                end if
	Rs.close
       set rs=nothing 
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                lui=sangong.namejian("pid",pid)
                mon=rs("money")
                if a=1000 and rs("a")<>1000 then
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)*1.5
                qingtian.pay -int(mon)*1.5,rs("nid")
                d=d-int(mon)*1.5
                rs("m")=rs("m")-int(mon) 
                elseif rs("a")=1000 and a<>1000 then
                rs("shen")=rs("shen")+1
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                rs("d")=int(mon)*(1-lui/100)*1.5
                qingtian.pay int(mon)*(1-lui/100)*1.5,rs("nid")
                d=int(mon)*1.5+d             
                elseif 22>rs("a") and rs("a")>a or (1000>a and a>21 and rs("a")<22) then
                rs("shen")=rs("shen")+1
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                rs("d")=int(mon)*(1-lui/100)
                qingtian.pay int(mon)*(1-lui/100),rs("nid")
                d=int(mon)+d  
                elseif rs("a")=a and rs("a")<22 then
                else
                rs("m")=rs("m")-int(mon)
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)
                qingtian.pay -int(mon),rs("nid")
                d=d-int(mon) 
                end if
	        rs.update                            
                end if
       Rs.close
       set rs=nothing     
          if sangong.namere("d",mynid)<0 then
          bodyy="很遗憾你输了,系统自动扣除你"&zi&""&abs(sangong.namere("d",mynid))&""&qingtian.bi&""&zi0&"!<br/>"
          qingtian.addong("在游戏[url=/game/21/index.asp?sid=[sid]]21点[/url]中输掉了"&qingtian.bi&"")        
          elseif sangong.namere("d",mynid)>0 then
          bodyy="恭喜,你赢了系统为你增加"&zi&""&namere("d",mynid)&""&qingtian.bi&""&zi0&"!<br/>"
          qingtian.addong("在游戏[url=/game/21/index.asp?sid=[sid]]21点[/url]中赢得了"&qingtian.bi&"") 
          else
          bodyy="你与庄家点数相同此局打和<br/>"
          end if
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then  
                if 1000>rs("a") and rs("a")>21 then
                aa="爆"
                elseif rs("a")=1000 then 
                aa="黑杰克"
                else
                aa=rs("a")&"点"
                end if
                if 1000>rs("a1") and rs("a1")>21 then
                aa1="爆"
                elseif rs("a1")=1000 then 
                aa1="黑杰克"
                else
                aa1=rs("a1")&"点"
                end if
                bodyy=bodyy&toname&"的牌(庄)："&aa1&"<br/>"&sangong.pai(rs("c1"))&"<br/>" 
                bodyy=bodyy&"你的牌："&aa&"<br/>"&sangong.pai(rs("c"))&"<br/>"                         
                end if
       Rs.close
       set rs=nothing 
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0
                rs("time")=now()
                rs("aid")=0
                rs("bid")=0
                rs("ku")=0
                rs("a")=0
                rs("c")=""
                rs("a1")=0
                rs("c1")=""
                rs("h")=""
                rs("d")=0
                rs("b")=0
	        rs.update
        end if
	Rs.close
       set rs=nothing
        bodyy=bodyy&"是否继续游戏:<br/>1.<a href='gamedd.asp?pid="&pid&"&amp;sid="&sidd&"'>继续</a><br/>2.<a href='gamedd.asp?act=4&amp;Action=login&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a><br/>" 
         gamejie2=bodyy
     End Function
    Public Function gamejie(str1,str2)
        dim rs,sql,strs,i,pp,tt,aa,a,nid,d,id,pid,bodyy
        id=str1
        pid=str2
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where aid="&id&" and ton=2 order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then  
                a=rs("a")
                nid=rs("nid")
                end if
	Rs.close
       set rs=nothing 

	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" and ton<>2 order by nid asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                lui=namejian("pid",pid)
 		For i=1 to rs.RecordCount
                mon=rs("money")
                if a=1000 and rs("a")<>1000 then
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)*1.5
                qingtian.pay -int(mon)*1.5,rs("nid")
                d=d-int(mon)*1.5
                rs("m")=rs("m")-int(mon) 
                elseif rs("a")=1000 and a<>1000 then
                rs("shen")=rs("shen")+1
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                rs("d")=int(mon)*(1-lui/100)*1.5
                qingtian.pay int(mon)*(1-lui/100)*1.5,rs("nid")
                d=int(mon)*1.5+d             
                elseif 22>rs("a") and rs("a")>a or (1000>a and a>21 and rs("a")<22) then
                rs("shen")=rs("shen")+1
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                rs("d")=int(mon)*(1-lui/100)
                qingtian.pay int(mon)*(1-lui/100),rs("nid")
                d=int(mon)+d  
                elseif rs("a")=a and rs("a")<22 then
                else
                rs("m")=rs("m")-int(mon)
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)
                qingtian.pay -int(mon),rs("nid")
                d=d-int(mon) 
                end if 
	        rs.update                            
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing              
        d=-d
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&nid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                if d>0 then
                d=d*(1-lui/100)
                rs("m")=rs("m")+d
                rs("shen")=rs("shen")+1
                else
                rs("m")=rs("m")+d
                rs("shu")=rs("shu")+1
                end if
                rs("d")=d
	rs.update
        end if
	Rs.close
       set rs=nothing 
                qingtian.pay d,nid
                
          if namere("d",qingtian.nid)<0 then
          bodyy="很遗憾你输了,系统自动扣除你"&zi&""&abs(namere("d",qingtian.nid))&""&qingtian.bi&""&zi0&"!<br/>"
          qingtian.addong("在游戏[url=/game/21/index.asp?sid=[sid]]21点[/url]中输掉了"&qingtian.bi&"")        
          elseif namere("d",qingtian.nid)>0 then
          bodyy="恭喜,你赢了系统为你增加"&zi&""&namere("d",qingtian.nid)&""&qingtian.bi&""&zi0&"!<br/>"
          qingtian.addong("在游戏[url=/game/21/index.asp?sid=[sid]]21点[/url]中赢得了"&qingtian.bi&"") 
          else
          bodyy="你与庄家点数相同此局打和<br/>"
          end if
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
 		For i=1 to rs.RecordCount
                if rs("nid")=qingtian.nid then
                tt="你的"
                else
                tt=qingtian.name(rs("nid"))
                end if
                if 1000>rs("a") and rs("a")>21 then
                aa="爆"
                elseif rs("a")=1000 then 
                aa="黑杰克"
                else
                aa=rs("a")&"点"
                end if
                if rs("nid")=nid then 
                pp=""&zi&"(庄)"&zi0&""
                else
                pp=""
                end if
                bodyy=bodyy&tt&"的牌"&pp&"："&zi&""&aa&""&zi0&"<br/>"&pai(rs("c"))&"<br/>"                          
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing 
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_fangd where id="&id&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=2
                rs("time")=now()
	rs.update 
        end if
	Rs.close
       set rs=nothing
          bodyy=bodyy&"请等待10秒[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>]<br/>"
         gamejie=bodyy
     End Function
    Public Function gamettt(str)
        dim id,kk,pp,tt,aa,rs,sql,i,bodyy
        id=str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
 		For i=1 to rs.RecordCount
                if rs("a")=1000 then 
                aa="黑杰克"
                elseif rs("a")>21 and rs("a")<1000 then
                aa="爆"
                else
                aa=rs("a")&"点"
                end if  
                if rs("nid")=qingtian.nid then
                if rs("ton")=2 then 
                pp=""&zi&"(庄)"&zi0&""
                else 
                pp=""
                end if
                tt="你的"
                kk=pai(rs("c"))
                else
                if rs("ton")=2 then
                pp=""&zi&"(庄)"&zi0&""
                aa="kong"
                else
                pp=""
                end if
                tt=qingtian.name(rs("nid"))
                kk=aapai(rs("c"))
                end if            
                bodyy=bodyy&""&tt&"的牌"&pp&"："&zi&""&aa&""&zi0&"<br/>"&kk&"<br/>"              
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing
       gamettt=bodyy
     End Function
end class
set sangong=new sangong_class
%>